#include<iostream>
#include<algorithm>
using namespace std;
const int N = 30;
int arr[N];
int n;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int mi = arr[0];
	for (int i = 0; i < n - 1; i++) {
		int t = arr[i];
		for (int j = i + 1; j < n; j++) {
			t &= arr[j];	
			mi = min(mi, t);
		}
	}
	cout << mi << endl;
	return 0;
}